﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MapletRemoteControl/Map24MapletRemoteControl.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the polyline to add
$longitudes	= "514.048|519.048|521.0196|523.04816|525.04816|527.4126|529.9816|532.8716|534.0116";
$latitudes	= "3007.8325|3005.9325|3006.14|3008.0025|3012.915|3010.552|3008.515|3010.315|3014.515";

// the color of the polyline
$Color['red'] = 0;
$Color['green'] = 0;
$Color['blue'] = 255;
$Color['alpha'] = 150;

//Color of the Arrow
$ArrowColor['red'] = 255;
$ArrowColor['green'] = 255;
$ArrowColor['blue'] = 255;
$ArrowColor['alpha'] = 255;

// zoomlevel
$mapViewClippingWidth = 5000;
$mapViewPercentage = 20;


//Flightproperties

//Name of the Groupe, which should be visit
$proIdx=0;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "Map24RouteObjectID";
$property[$proIdx]->Value 	= "FLIGHTLOCS";

//FlightSpeed
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightSpeed";
$property[$proIdx]->Value	= 300;

//Zoom
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightZoom";
$property[$proIdx]->Value	= 1000;

//LandingSpeed
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightLandingSpeed";
$property[$proIdx]->Value	= 20;

//LandingLengthPercentage
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightLandingLengthPercentage";
$property[$proIdx]->Value	= 3;

//To reverse the flight
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "FlightReverse";
$property[$proIdx]->Value	= false;

//To start the flight automatically
$proIdx++;
$property[$proIdx]=new Property();
$property[$proIdx]->Key		= "Control";
$property[$proIdx]->Value 	= "Start";


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will add a new Polyline
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMap24Polyline = new DeclareMap24Polyline();
$commands[$cmdIdx]->DeclareMap24Polyline->MapObjectID = "polyline";
$commands[$cmdIdx]->DeclareMap24Polyline->Coordinates = new CoordinatesArray();
$commands[$cmdIdx]->DeclareMap24Polyline->Coordinates->Longitudes = $longitudes;
$commands[$cmdIdx]->DeclareMap24Polyline->Coordinates->Latitudes = $latitudes;
$commands[$cmdIdx]->DeclareMap24Polyline->Color = new Color();
$commands[$cmdIdx]->DeclareMap24Polyline->Color->red = $Color['red'];
$commands[$cmdIdx]->DeclareMap24Polyline->Color->green = $Color['green'];
$commands[$cmdIdx]->DeclareMap24Polyline->Color->blue = $Color['blue'];
$commands[$cmdIdx]->DeclareMap24Polyline->Color->alpha = $Color['alpha'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor = new Color();
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->red = $ArrowColor['red'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->green = $ArrowColor['green'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->blue = $ArrowColor['blue'];
$commands[$cmdIdx]->DeclareMap24Polyline->ArrowColor->alpha = $ArrowColor['alpha'];

// this will add the objects to a Grupp
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->DeclareMapObjectGroup = new DeclareMapObjectGroup();
$commands[$cmdIdx]->DeclareMapObjectGroup->MapObjectGroupID = "FLIGHTLOCS";
$commands[$cmdIdx]->DeclareMapObjectGroup->MapObjectIDs = array("polyline");

// this object will enable the new location on the map
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlMapObject = new ControlMapObject();
$commands[$cmdIdx]->ControlMapObject->Control = "ENABLE";
$commands[$cmdIdx]->ControlMapObject->MapObjectIDs = array('FLIGHTLOCS');

// Slide out the equired components for the heli flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "SHOWM3D";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";

// Enable the required components for the heli flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "SHOWM3DROUTE";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";

//  Pass the flight locations to the route component and set some additional properties for the flight
$cmdIdx++;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->ControlComponent = new ControlComponent();
$commands[$cmdIdx]->ControlComponent->Component= "M3DROUTE";
$commands[$cmdIdx]->ControlComponent->Control= "SHOW";
$commands[$cmdIdx]->ControlComponent->Properties=$property;


// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new MapletRemoteControlRequest();
$request->Map24MRC = new Map24MRC();
$request->Map24MRC->Commands = $commands;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mrc = new Map24MapletRemoteControl($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mrc->mapletRemoteControl($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------


$resultString = "This command generates no output";
$counter = 0;


?>